#ifndef _KTV_STD_EX_H_
#define _KTV_STD_EX_H_

#include <string>
#include <vector>
#include <limits>
#include <stdexcept>

namespace stdex
{
std::string itoa(const int iValue);
std::string ltoa(const long lValue);
std::string ftoa(const float fValue);
std::string dtoa(const double dValue);
int atoi(const std::string& sValue);
long int atol(const std::string& sValue);
float atof(const std::string& sValue);
double atod(const std::string& sValue);
std::string TrimString(const std::string& sString);
std::string Tostring(const char* sString);
std::string ToMbString(const std::string& sstring);
std::vector<std::string> DetokenizeString(const std::string& sString, const std::string& sDelimiters);
#ifdef WIN32
#pragma warning (push)
#pragma warning (disable : 4018)  // temporarily disable signed/unsigned comparison warning
#endif  // WIN32
template<typename TDest, typename TSrc>
TDest safe_static_cast(const TSrc& Value)
{
#ifndef MSVC6
	bool bSpecialized = std::numeric_limits<TDest>::is_specialized && std::numeric_limits<TDest>::is_bounded;
	bool bNotSigned = ! std::numeric_limits<TDest>::is_signed;
	if (bSpecialized && ((bNotSigned && Value < std::numeric_limits<TDest>::min()) || Value > std::numeric_limits<TDest>::max()))
	{
		throw std::out_of_range("safe_static_cast : Out of range!");
	}
#endif
	return static_cast<TDest>(Value);
}
#ifdef WIN32
#pragma warning (default : 4018)  // reenable signed/unsigned comparison warning
#pragma warning (pop)
#endif  // WIN32

}

#endif  // _KTV_STD_EX_H_
